package com.zhisland.base.support;

import com.zhisland.base.support.common.mybaits.interceptor.DialectResultSetHandlerInterceptor;
import com.zhisland.base.support.common.mybaits.interceptor.DialectStatementHandlerInterceptor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

/**
 * 作者: guo yao
 * 日期: 2016年11月16日
 * 时间: 下午14:45
 */
@EnableWebMvc
@SpringBootApplication
public class SpringBootMain extends SpringBootServletInitializer implements CommandLineRunner {


    // 启动执行的代码
    @Override
    public void run(String... args) throws Exception {
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringBootMain.class);
    }


    public static void main(String[] args) {
        SpringApplication.run(SpringBootMain.class, args);
    }


    // 配置mybatis拦截器
    @Bean
    public DialectStatementHandlerInterceptor dialectStatementHandlerInterceptor() {
        return new DialectStatementHandlerInterceptor();
    }

    @Bean
    public DialectResultSetHandlerInterceptor dialectResultSetHandlerInterceptor() {
        return new DialectResultSetHandlerInterceptor();
    }


}
